package com.example.mybatisdemo.mapper;

import com.example.mybatisdemo.model.ArticleInfo;
import com.example.mybatisdemo.model.UserInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface ArticleInfoMapper {
    @Select("select * from articleinfo where id = #{articleId")
    ArticleInfo selectById(Integer articleId);

    @Select("select * from userinfo where id=1")
    UserInfo queryById(@Param("userid") Integer id);

    //多表查询
    @Select("select ta.*,tb.username,tb.age from" +
            " articleinfo ta LEFT JOIN userinfo tb on ta.uid = tb.id" +
            " where ta.id=1")
    ArticleInfo selectArticleAndUserById(Integer articleId);

}
